# 获取登录成功的令牌,拼接请求头,返回

# 导包
import requests


# 定义函数
def get_header():
    session = requests.session()
    url = "http://ihrm-test.itheima.net/api/sys/login"
    json_data = {"mobile": "13800000002", "password": "123456"}
    res = session.post(url=url, json=json_data)
    print(res.json())
    # 从响应体中,获取data的值
    token = res.json().get("data")
    print("token=", token)

    header = {"Content-Type": "application/json", "Authorization": "Bearer " + token}
    print("header=", header)
    return header

if __name__ == '__main__':
    get_header()